class ClusterRecommendations < ActiveRecord::Migration
  def self.up
    remove_index :recommendations, :entry_id
    add_index :recommendations, :entry_id, :name => "index_recommendations_on_entry_id"
    execute "ALTER TABLE recommendations CLUSTER ON index_recommendations_on_entry_id"
    execute "UPDATE feeds SET harvested_from_title = 'LACLO-FLOR', harvested_from_short_title = 'LACLO-FLOR' WHERE short_title = 'LACLO-FLOR'"
    add_column :feeds, :entries_count, :integer
    execute "UPDATE feeds SET entries_count = (SELECT count(*) FROM entries WHERE feed_id = feeds.id)"
  end
  
  def self.down
    remove_column :feeds, :entries_count
  end
end